using System;
using System.Reflection;
using SwinGame;
using Color = System.Drawing.Color;

namespace Survivor.src
{
    public class GameMain
    {
        public static void Main()
        {
            //Start the audio system so sound can be played
            Audio.OpenAudio();
            StateManager stateManager = new StateManager();

            IntroState startState = new IntroState(stateManager);
            
            stateManager.AddChild(startState);
            stateManager.Load();
            //Textbox t = new Textbox(32,32,64,16,"New Game");
            //Open the game window
            Graphics.OpenGraphicsWindow("GameMain", 800, 600);

            //Run the game loop
            while (false == Input.WindowCloseRequested() && stateManager.isRunning())
            {
                //Fetch the next batch of UI interaction
                Input.ProcessEvents();

                stateManager.Update(Utils.GetTicks());

                //Clear the screen and draw the framerate
                Graphics.ClearScreen(Color.White);

                stateManager.Draw(Utils.GetTicks());
                //Text.DrawFramerate(0, 0);
                //t.Draw();
                //if (t.isPressed()) { Console.WriteLine("Pressed"); }
                //Draw onto the screen
                Graphics.RefreshScreen();
            }

            //End the audio
            Audio.CloseAudio();

            //Close any resources we were using
            Resources.ReleaseAllResources();
        }
    }
}